# Copyright 2018- The Pixie Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "controllers",
    srcs = [
        "api_key_grpc.go",
        "api_key_resolver.go",
        "artifact_resolver.go",
        "artifact_tracker.go",
        "auth.go",
        "auth_client.go",
        "auth_grpc.go",
        "autocomplete_grpc.go",
        "autocomplete_resolver.go",
        "cluster_name.go",
        "cluster_resolver.go",
        "config_grpc.go",
        "deploy_key_grpc.go",
        "deployment_key_resolver.go",
        "gql.go",
        "org_grpc.go",
        "org_resolver.go",
        "script_grpc.go",
        "scriptmgr_resolver.go",
        "session.go",
        "session_middleware.go",
        "user_grpc.go",
        "user_resolver.go",
        "vizier_cluster_grpc.go",
        "vizier_image_auth_grpc.go",
    ],
    importpath = "px.dev/pixie/src/cloud/api/controllers",
    visibility = ["//src/cloud:__subpackages__"],
    deps = [
        "//src/api/proto/cloudpb:cloudapi_pl_go_proto",
        "//src/api/proto/uuidpb:uuid_pl_go_proto",
        "//src/api/proto/vizierconfigpb:vizier_pl_go_proto",
        "//src/cloud/api/apienv",
        "//src/cloud/api/controllers/schema/complete",
        "//src/cloud/api/controllers/schema/noauth",
        "//src/cloud/artifact_tracker/artifacttrackerpb:artifact_tracker_pl_go_proto",
        "//src/cloud/auth/authpb:auth_pl_go_proto",
        "//src/cloud/autocomplete",
        "//src/cloud/config_manager/configmanagerpb:service_pl_go_proto",
        "//src/cloud/profile/profilepb:service_pl_go_proto",
        "//src/cloud/scriptmgr/scriptmgrpb:service_pl_go_proto",
        "//src/cloud/vzmgr/vzmgrpb:service_pl_go_proto",
        "//src/shared/artifacts/versionspb:versions_pl_go_proto",
        "//src/shared/cvmsgspb:cvmsgs_pl_go_proto",
        "//src/shared/k8s/metadatapb:metadata_pl_go_proto",
        "//src/shared/services",
        "//src/shared/services/authcontext",
        "//src/shared/services/env",
        "//src/shared/services/events",
        "//src/shared/services/handler",
        "//src/shared/services/httpmiddleware",
        "//src/shared/services/utils",
        "//src/utils",
        "@com_github_dgrijalva_jwt_go_v4//:jwt-go",
        "@com_github_gofrs_uuid//:uuid",
        "@com_github_gogo_protobuf//jsonpb",
        "@com_github_gogo_protobuf//types",
        "@com_github_gorilla_sessions//:sessions",
        "@com_github_graph_gophers_graphql_go//:graphql-go",
        "@com_github_graph_gophers_graphql_go//relay",
        "@com_github_sirupsen_logrus//:logrus",
        "@com_github_spf13_pflag//:pflag",
        "@com_github_spf13_viper//:viper",
        "@in_gopkg_segmentio_analytics_go_v3//:analytics-go_v3",
        "@org_golang_google_grpc//:go_default_library",
        "@org_golang_google_grpc//codes",
        "@org_golang_google_grpc//metadata",
        "@org_golang_google_grpc//status",
    ],
)

go_test(
    name = "controllers_test",
    srcs = [
        "api_key_resolver_test.go",
        "api_key_test.go",
        "artifact_resolver_test.go",
        "artifact_tracker_test.go",
        "auth_grpc_test.go",
        "auth_test.go",
        "autocomplete_resolver_test.go",
        "autocomplete_test.go",
        "cluster_name_test.go",
        "cluster_resolver_test.go",
        "config_grpc_test.go",
        "deployment_key_resolver_test.go",
        "deployment_key_test.go",
        "org_resolver_test.go",
        "org_test.go",
        "script_test.go",
        "scriptmgr_resolver_test.go",
        "session_middleware_test.go",
        "user_resolver_test.go",
        "user_test.go",
        "vizier_cluster_test.go",
    ],
    embed = [":controllers"],
    deps = [
        "//src/api/proto/cloudpb:cloudapi_pl_go_proto",
        "//src/api/proto/uuidpb:uuid_pl_go_proto",
        "//src/api/proto/vispb:vis_pl_go_proto",
        "//src/api/proto/vizierconfigpb:vizier_pl_go_proto",
        "//src/cloud/api/apienv",
        "//src/cloud/api/controllers/schema/complete",
        "//src/cloud/api/controllers/schema/noauth",
        "//src/cloud/api/controllers/testutils",
        "//src/cloud/artifact_tracker/artifacttrackerpb:artifact_tracker_pl_go_proto",
        "//src/cloud/auth/authpb:auth_pl_go_proto",
        "//src/cloud/auth/authpb/mock",
        "//src/cloud/autocomplete",
        "//src/cloud/autocomplete/mock",
        "//src/cloud/config_manager/configmanagerpb:service_pl_go_proto",
        "//src/cloud/profile/profilepb:service_pl_go_proto",
        "//src/cloud/scriptmgr/scriptmgrpb:service_pl_go_proto",
        "//src/cloud/scriptmgr/scriptmgrpb/mock",
        "//src/cloud/vzmgr/vzmgrpb:service_pl_go_proto",
        "//src/shared/artifacts/versionspb:versions_pl_go_proto",
        "//src/shared/cvmsgspb:cvmsgs_pl_go_proto",
        "//src/shared/k8s/metadatapb:metadata_pl_go_proto",
        "//src/shared/services/authcontext",
        "//src/shared/services/handler",
        "//src/shared/services/utils",
        "//src/utils",
        "//src/utils/testingutils",
        "@com_github_dgrijalva_jwt_go_v4//:jwt-go",
        "@com_github_gofrs_uuid//:uuid",
        "@com_github_gogo_protobuf//proto",
        "@com_github_gogo_protobuf//types",
        "@com_github_golang_mock//gomock",
        "@com_github_graph_gophers_graphql_go//:graphql-go",
        "@com_github_graph_gophers_graphql_go//gqltesting",
        "@com_github_spf13_viper//:viper",
        "@com_github_stretchr_testify//assert",
        "@com_github_stretchr_testify//require",
        "@org_golang_google_grpc//:go_default_library",
        "@org_golang_google_grpc//codes",
        "@org_golang_google_grpc//metadata",
        "@org_golang_google_grpc//status",
    ],
)
